<?php
/* Generate source data for checking serialization/unserialization 

   Usage:
     php -q generate.php > data.in

   data.in format:
     [num]   - starts line with description/dump of serialized var
     [ ]     - starts line with output from the serialization function
*/ 

$data = array(
0,
65535,
-1,
-34.535235,
"simple string",
'with " inside',
"\nsome\nlinefeeds\n",
NULL,
True,
False,
array(4, 0.234, "another \n string", -0.000001),
// add some big ints
-PHP_INT_MAX,
PHP_INT_MAX+1,
);

// var_dump($data);


foreach ($data as $i => $v) {

   $s = serialize($v);
   print "\n[$i] (".gettype($v).") ".var_export($v, true)."\n[ ] ".$s;
   if (!is_array($v)) {
       $t = unserialize($s);
       if ($v !== $t) {
           print "WARNING: native PHP serialization is not symmetrical";
       }
   }

}
